#include "UIButton.h"
#include "s3e.h"

void UIButton::Load( const char* file, const CIwSVec2& pos )
{
	m_pos = pos;

	m_sprite.Load( file );
	m_touch.CalcSizeForSprite( m_sprite );
	m_touch.SetPos( CIwFVec2( (float)m_pos.x, (float)m_pos.y ) );
}

void UIButton::Unload()
{
	m_sprite.Unload();
}
		
void UIButton::Draw()
{
	m_sprite.Draw( m_pos );
}

void UIButton::Update( float dt )
{
	(void) dt;
}
	
bool UIButton::IsPressed() const
{
	if( s3ePointerGetTouchState( 0 ) & S3E_POINTER_STATE_RELEASED && m_touch.IsWithin( 0 ) ) {
		return true;
	}
	
	return false;
}